<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>解析location对象(实例)</title>
</head>
<body>

    <div style="height: 600px;">first</div>
    <a name="middle"></a>
    <div style="height: 600px;">second</div>
    <hr>
    <div style="height: 600px;">third</div>
    <a href="#middle">返回</a>

    <script type="text/javascript">

        let names = Object.getOwnPropertyNames( Location );
        console.log( names );

        names = Object.getOwnPropertyNames( Location.prototype );
        console.log( names );

        console.log( '- - - '.repeat(5) );

        console.log( location instanceof Location );

        names = Object.getOwnPropertyNames( location );
        console.log( names );

        console.log( '- - - '.repeat(5) );

        let protocol = location.protocol ; // 协议
        console.log( protocol );

        let hostname = location.hostname ; // 主机
        console.log( hostname );

        let port = location.port ; // 端口
        console.log( port );

        let pathname = location.pathname ; // 路径名称
        console.log( pathname );

        let hash = location.hash ;
        console.log( hash );

        let search = location.search ; // 查询字符串
        console.log( search );

        let host = location.host;
        console.log( host );

        let origin = location.origin;
        console.log( origin );

        console.log( '- - - '.repeat(5) );

        console.log( typeof location );
        let another = location.valueOf();
        console.log( another );
        console.log( typeof another );

        console.log( location === another );

        let url = location.toString();
        console.log( url );

    </script>
    
</body>
</html>